/* =================================================================
 * Waldameisen Ernährung - Modern Responsive Stylesheet
 * Projekt: Ameisen-Webseite (angelehnt an hm-noroc.de)
 * Farbschema: Moderne Wald- und Erdtöne (Forest & Earth Tones)
 * ================================================================= */

/* --- CSS Variablen / Design Tokens --- */
:root {
    --color-primary: #2C4C3B;      /* Tiefes Waldgrün */
    --color-secondary: #4A7C59;    /* Salbeigrün / Akzent */
    --color-accent: #BC6C25;       /* Warmes Ocker / Bernstein */
    --color-bg: #F4F6F0;           /* Sanfter Erdtton / Hellgrau-Grün */
    --color-surface: #FFFFFF;      /* Weiß für Karten & Container */
    --color-text: #2B2D42;         /* Dunkelgrau für optimale Lesbarkeit */
    --color-text-muted: #555B6E;   /* Milder Text für Nebeninfos */
    --color-border: #D8E2DC;       /* Subtiler Rahmen */
    --transition-speed: 0.3s;
}

/* --- Globale Stile & Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth; /* Weiches Scrollen bei Sprungmarken */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 1rem;
}

/* --- Layout: Desktop Grid (3 Spalten: 20% | 60% | 20%) --- */
.page-container {
    display: grid;
    grid-template-columns: 20% 60% 20%;
    min-height: 100vh;
    width: 100%;
}

/* Linke Spalte: Navigation */
.sidebar-left {
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-left h2 {
    font-size: 1.25rem;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-secondary);
}

.nav-menu {
    list-style: none;
}

.nav-menu li {
    margin-bottom: 0.75rem;
}

.nav-menu a {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    border-radius: 6px;
    transition: background var(--transition-speed), color var(--transition-speed);
}

.nav-menu a:hover,
.nav-menu a.active {
    background-color: var(--color-primary);
    color: #ffffff;
}

/* Mittlere Spalte: Hauptinhalt */
.main-content {
    background-color: var(--color-surface);
    padding: 2.5rem 3rem;
    box-shadow: 0 0 20px rgba(0,0,0,0.02);
}

.main-content h1 {
    font-size: 2.2rem;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
}

.main-content h2 {
    font-size: 1.6rem;
    color: var(--color-secondary);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--color-border);
}

.main-content p {
    margin-bottom: 1.2rem;
    color: var(--color-text);
}

/* Rechte Spalte: Leer / Dekorative Spalte */
.sidebar-right {
    background-color: var(--color-bg);
    padding: 2rem;
}

/* --- Inhaltsverzeichnis / Sprungmarken (oben im Hauptinhalt) --- */
.toc-box {
    background-color: var(--color-bg);
    border-left: 4px solid var(--color-accent);
    padding: 1.2rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 0 8px 8px 0;
}

.toc-box h3 {
    font-size: 1.1rem;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.toc-list {
    list-style-type: disc;
    padding-left: 1.2rem;
}

.toc-list li {
    margin-bottom: 0.4rem;
}

.toc-list a {
    color: var(--color-secondary);
    text-decoration: none;
    font-weight: 500;
}

.toc-list a:hover {
    text-decoration: underline;
    color: var(--color-accent);
}

/* --- Verschachtelte Listen (Gliederungen / Mehrstufige Auflistungen) --- */
.nested-list {
    list-style-type: disc;
    margin: 1.2rem 0;
    padding-left: 1.5rem;
}

.nested-list li {
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

/* 2. Ebene (Unterliste) */
.nested-list ul {
    list-style-type: circle;
    margin: 0.5rem 0 0.5rem 1.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--color-border);
}

.nested-list ul li {
    margin-bottom: 0.4rem;
    color: var(--color-text);
}

/* 3. Ebene (Unter-Unterliste) */
.nested-list ul ul {
    list-style-type: square;
    margin: 0.4rem 0 0.4rem 1.2rem;
    border-left: 2px dotted var(--color-secondary);
}

.nested-list ul ul li {
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

/* --- Responsive Bilder mit Rahmen und Bildunterschrift --- */
.image-figure {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    padding: 8px;
    margin: 1.5rem 0;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.03);
    max-width: 100%;
}

.image-figure img {
    max-width: 100%;       /* Passt sich kleineren Bildschirmen flexibel an */
    width: auto;           /* Verhindert das Aufblähen über die Originalgröße hinaus */
    height: auto;          /* Behält das Seitenverhältnis bei */
    display: block;
    margin: 0 auto;        /* Zentriert das Bild im Rahmen */
    border-radius: 4px;
}

.image-caption {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

/* --- Saubere HTML-Tabellen --- */
.table-container {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    text-align: left;
    background-color: #ffffff;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.styled-table th,
.styled-table td {
    padding: 12px 15px;
}

.styled-table th {
    background-color: var(--color-primary);
    color: #ffffff;
    font-weight: 600;
}

.styled-table tbody tr {
    border-bottom: 1px solid var(--color-border);
}

.styled-table tbody tr:nth-of-type(even) {
    background-color: rgba(216, 226, 220, 0.2);
}

.styled-table tbody tr:last-of-type {
    border-bottom: 2px solid var(--color-primary);
}

/* --- Literatur & Weblinks Bereich --- */
.references-section {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--color-border);
}

.references-section h2 {
    font-size: 1.4rem;
    color: var(--color-primary);
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: none;
}

.references-section h3 {
    font-size: 1.1rem;
    color: var(--color-secondary);
    margin-top: 1.2rem;
    margin-bottom: 0.6rem;
}

.reference-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}

.reference-list li {
    padding: 0.5rem 0.8rem;
    margin-bottom: 0.4rem;
    background-color: var(--color-bg);
    border-left: 3px solid var(--color-secondary);
    border-radius: 0 4px 4px 0;
    font-size: 0.93rem;
}

.link-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}

.link-list li {
    margin-bottom: 0.5rem;
}

.link-list a {
    color: var(--color-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.link-list a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

/* --- Sprungmarke: Zurück zum Seitenanfang --- */
.back-to-top {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding: 0.6rem 1.2rem;
    background-color: var(--color-bg);
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    transition: background-color var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed);
}

.back-to-top:hover {
    background-color: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}

/* --- Mobile Burger Menü (Natives CSS ohne JS) --- */
.mobile-header {
    display: none; /* Nur auf Mobilgeräten sichtbar */
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 1rem;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.menu-toggle-checkbox {
    display: none;
}

.menu-toggle-label {
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 30px;
}

.menu-toggle-label span {
    display: block;
    height: 3px;
    background-color: #ffffff;
    border-radius: 2px;
    transition: var(--transition-speed);
}

/* --- Media Queries für Responsive Design --- */

/* Tablets (Bildschirme kleiner als 1024px) -> 2 Spalten, rechte Spalte unsichtbar */
@media screen and (max-width: 1023px) {
    .page-container {
        grid-template-columns: 25% 75%;
    }
    .sidebar-right {
        display: none;
    }
    .main-content {
        padding: 2rem;
    }
}

/* Handys / Smartphones (Bildschirme kleiner als 768px) -> 1 Spalte, aufklappbares Menü */
@media screen and (max-width: 767px) {
    .page-container {
        display: block;
    }

    .mobile-header {
        display: flex;
    }

    /* Sidebar wird zum mobilen Dropdown/Slide-Down Menü */
    .sidebar-left {
        position: static;
        height: auto;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        padding: 0 1.5rem;
        background-color: var(--color-surface);
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
    }

    /* Checkbox-Hack zum Ein-/Ausklappen des Menüs */
    .menu-toggle-checkbox:checked ~ .page-container .sidebar-left {
        max-height: 75vh;
        overflow-y: auto;
        padding: 1.5rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .main-content h1 {
        font-size: 1.75rem;
    }

    .main-content h2 {
        font-size: 1.3rem;
    }
}
